﻿/**************************************************
* Testa se possui somente números
**************************************************/
function ValidaSomenteNumero(texto) 
{
    if (texto == "")
        return true;

    var exp = /^[0-9]+$/;
    return exp.test(texto);
}
/**************************************************
* Desabilita teclas nÃ£o numÃ©ricas (exceto backspace) em um controle
* Associar no evento: onkeypress()
**************************************************/
function SomenteNumero(e) {
    var whichCode = (e.which) ? e.which : e.keyCode;

    if (whichCode == 9) //Tab ou Shift+Tab
        return true;
    else if (e.shiftKey)
        return false;
    else if (e.ctrlKey && whichCode == 99)//CTRL+C
        return true;
    else if (e.ctrlKey && whichCode == 118)//CTRL+V
        return true;
    else if (whichCode >= 48 && whichCode <= 57) //0-9
        return true;
    else if (whichCode == 8) //BackSpace
        return true;
    else
        return false;

}
